﻿@model List<CMP.ERP.Model.DetailsShipments>
@{
    Layout = null;
}

@Html.Action("Account_Show", "Account");
<div class="content">
    <div class="right" id="mainFrame">
        <div class="right_cont">
            <div class="header">
                <div class="header-right">

                </div>
            </div>
            <!-- 顶部 -->

            <div id="middle">

                <div class="Switch"></div>
                <script type="text/javascript">
                    $(document).ready(function (e) {
                        $(".Switch").click(function () {
                            $(".left").toggle();

                        });
                    });
                </script>
                <div class="right" id="mainFrame">
                    <div class="right_cont">
                        <ul class="breadcrumb">
                            当前位置：
                            <a href="/Home/Index">首页</a>
                            <span class="divider">/</span>
                            订单详情信息
                        </ul>
                        <div class="title_right"><strong>知行系统管理</strong></div>
                        <div style="width:100%; margin:auto">
                            <div style="margin-top:20px;">
                                <table class="table  table-hover table-bordered table-striped" id="por">
                                    <thead>
                                        <tr>
                                            <td>订单编号</td>
                                            <th>下单时间</th>
                                            <th>收货人</th>
                                            <th>联系方式</th>
                                            <th>订单状态</th>
                                            <th>快递名称</th>
                                            <th>仓库名称</th>
                                            <th>总金额</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                                <br />
                                <table class="table  table-hover table-bordered table-striped">
                                    <thead>
                                        <tr>
                                            <td><input id="Checkbox1" type="checkbox" onclick="fcc()" /></td>
                                            <td>编号</td>
                                            <th>商品名称</th>
                                            <th>商品编码</th>
                                            <th>商品重量</th>
                                            <th>购买数量</th>
                                            <th>商品备注</th>
                                            <th>商品价格</th>
                                            <th>商品类型名称</th>
                                        </tr>
                                    </thead>
                                    <tbody>

                                        @foreach (var item in Model)
                                        {
                                            <tr>
                                                <td><input id="Checkbox1" name="ck" type="checkbox" onclick="fcc1()" value="@item.ShipmentMate_Id" /></td>
                                                <td>@item.ShipmentMate_Id<input id="Text1" type="hidden" value="@item.Shipments_Id" /></td>
                                                <td>@item.Commodity_Name</td>
                                                <td>@item.Commodity_number</td>
                                                <td>@item.Commodity_Weight</td>
                                                <td>@item.ShipmentMate_Num</td>
                                                <td>@item.Commodity_Remark</td>
                                                <td>@item.Commodity_Price</td>
                                                <td>@item.CommodityType_Name</td>
                                            </tr>
                                        }

                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <button type="button" class="btn btn-default" onclick="Outo()"><span class="icon-search"></span>审核完成并发货</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $.ajax({
            type: "get",
            url: "/Order/DetailsShipmentsShow2",
            data: {
                id:@Session["id"],
            },
            success: function (data) {
                $(data).each(function (index,item) {
                    var ss = "<tr><td>" + item.Shipments_Id + "</td><td>"+item.Shipments_data+"</td><td>" + item.Shipments_Per + "</td><td>" + item.Shipments_Phone + "</td><td>" + item.Shipments_State + "</td><td>" + item.Express_Company_Name + "</td><td>" + item.WareHose_Name + "</td><td>" + item.Shipments_SumMoney + "</td></tr>";
                    $("#por tbody").append(ss);
                })
            }
        })
    })

    function fcc()
    {
        if($("#Checkbox1").attr("checked")=="checked")
        {
            $(":checkbox").attr("checked","checked");
        }
        else
        {
            $(":checkbox").removeAttr("checked","checked");
        }
    }
    function fcc1()
    {
        if ($("[name='ck']:checked").length == $("[name='ck']").length) {
            $("#Checkbox1").attr("checked", "checked");
        } 
        else
        {
            $("#Checkbox1").removeAttr("checked");
        }
        var selectvalue = "";
        var emplist = $("[name='ck']:checked");
        $(emplist).each(function (index, p) {
            if (selectvalue.length > 0) {
                selectvalue += ",";
            }
            selectvalue += $(p).val();
        })
    }

    function Outo()
    {
        var selectvalue = "";
        var emplist = $("[name='ck']:checked");
        $(emplist).each(function (index, p) {
            if (selectvalue.length > 0) {
                selectvalue += ",";
            }
            selectvalue += $(p).val();
        })

        $.ajax({
            type:"post",
            url:"/Order/update",
            data:{
                pidtr:selectvalue
            },
            success:function(data){

                if(data=="True")
                {
                    alert("已发货");
                    location.href='/Fahuo/FahuoList';
                }
                else
                {
                    alert("Oh，no！");
                }
            }

        })
    }
</script>

